﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using XNADota.ContentPipeline.Data;
using XNADota.GamePlay;
using XNADota.Input;

namespace XNADota.UI
{
    public class CommanderScreen : IInputHandler
    {
        public const int MaxInventoryCount = 6;
        public const int MaxAbilityCount = 12;

        private Label[] _PandaUITileLabel;
        private MiniMap _MiniMap;

        private InventoryPanel _InventoryPanel;
        private ControlPanel _ControlPanel;

        private Cursor _Cursor;

        public ControlPanel ControlPanel
        {
            get { return _ControlPanel; }
        }

        public Panel InventoryPanel
        {
            get { return _InventoryPanel; }
        }

        public CommanderScreen(Game game)
        {
            XNADota.Instance.InputManager.Add(this);

            _PandaUITileLabel = new Label[8];
            for (int i = 0; i < 8; i++)
            {
                string name = string.Format("Data//UI//panda//PandaUITile{0:D2}", i + 1);
                LabelSetting setting = game.Content.Load<LabelSetting>(name);
                _PandaUITileLabel[i] = new Label(game, setting);
            }

            _MiniMap = new MiniMap(game);

            PanelSetting panelSetting;
            panelSetting = game.Content.Load<PanelSetting>("Data//UI//CommanderScreen//InventoryPanel");
            _InventoryPanel = new InventoryPanel(game, panelSetting);

            panelSetting = game.Content.Load<PanelSetting>("Data//UI//CommanderScreen//ControlPanel");
            _ControlPanel = new ControlPanel(game, panelSetting);

            _Cursor = new Cursor(game);
        }

        public void Update(GameTime gameTime)
        {
        }

        public void Draw(GameTime gameTime)
        {
            for (int i = 0; i < 8; i++)
            {
                _PandaUITileLabel[i].Draw(gameTime);
            }

            _InventoryPanel.Draw(gameTime);

            _ControlPanel.Draw(gameTime);

            _MiniMap.Draw(gameTime);
        }

        public void ProcessInput(GameTime gameTime, InputState inputState)
        {
            _ControlPanel.ProcessInput(gameTime, inputState);
            _InventoryPanel.ProcessInput(gameTime, inputState);
            _MiniMap.ProcessInput(gameTime, inputState);
        }
    }
}
